package com.yc.web.controller;


import com.yc.web.controller.model.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.java.Log;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

@RestController
@Tag(name = "Hello", description = "Hello Application")
@Log
public class HelloController {

    private static final List<String> HELLO_WORLDS = Arrays.asList(
            "Hello World",
            "你好，世界",
            "Hola Mundo",
            "Bonjour le monde",
            "こんにちは世界",
            "안녕하세요 세계",
            "Привет, мир",
            "Hallo Welt",
            "Ciao mondo",
            "สวัสดีชาวโลก"
    );

    private final Random random = new Random();
    @Operation(summary = "说你好", description = "后端会传输不同语言的hello world")
    @GetMapping(value = "/hello")
    public ResponseResult hello() {
        log.info("有请求来了，访问hello方法");
        String randomHello = HELLO_WORLDS.get(random.nextInt(HELLO_WORLDS.size()));
        return ResponseResult.ok().setData(randomHello);
    }
}